home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
cmln0186.arc
/
CROSSTH2.LTG
< prev
next >
Wrap
Text File
|
1986-12-20
|
2KB
|
54 lines
Listing 2.
PPL code for the concurrent quicksort.
EXPLICITLY RECURSIVE
NONEXCLUSIVELY CONCURRENT PROCEDURE QuikSort(VAR L : array of data records;
Left, Right : integer);
BEGIN
Priority = 1; Num_Slave_CPU = 1 -- This is a global identifier
I = Left; J = Right;
INITIALIZE: Median = L[(Left + Right) DIV 2)]
LOOP <Outer>
BEGIN
INITIALIZE:
LOOP <Incr_Left_Counter>
BEGIN IF L[I].Key >= Median.Key THEN EXIT END IF
I += 1
END LOOP <Incr_Left_Counter>
TERMINATE: None
INITIALIZE:
LOOP <Decr_Right_Counter>
BEGIN IF Median.Key >= L[J].Key THEN EXIT END IF
J -= 1
END LOOP <Dicr_Right_Counter>
TERMINATE: None
IF I <= J THEN Swap records L[I] and L[J]
I += 1; J -= 1
END IF
IF I > J THEN EXIT <Outer> END IF
END LOOP <Outer>
TERMINATE: None
IF Left < J THEN
IF Num_Slave_CPU < MAX_CPU
THEN Num_Slave_CPU += 1;
StartProcedure(QuickSort(L,Left,J),Priority,Signal[Num_Slave_CPU])
ELSE QuickSort(L,Left,J) END IF
END IF
IF I < Right THEN
IF Num_Slave_CPU < MAX_CPU
THEN Num_Slave_CPU += 1;
StartProcedure(QuickSort(L,I,Right),Priority,Signal[Num_Slave_CPU])
ELSE QuickSort(L,I,Right) END IF
END IF
Wait for pending signals
END QuickSort